﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace Lgc_VoteSys.Models.Database
{
    public partial class Lgc_VoteSysContext : DbContext
    {
        public Lgc_VoteSysContext()
        {
        }

        public Lgc_VoteSysContext(DbContextOptions<Lgc_VoteSysContext> options)
            : base(options)
        {
        }

        public virtual DbSet<EnterpriseDetail> EnterpriseDetails { get; set; }
        public virtual DbSet<User> Users { get; set; }
        public virtual DbSet<Vote> Votes { get; set; }
        public virtual DbSet<VotingRecord> VotingRecords { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=Lgc_VoteSys;Integrated Security=SSPI");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<EnterpriseDetail>(entity =>
            {
                entity.HasKey(e => e.No)
                    .HasName("PK__Enterpri__3214D4A89277153F");

                entity.Property(e => e.EdId)
                    .IsRequired()
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("ED_id");

                entity.Property(e => e.EdLogo)
                    .IsRequired()
                    .IsUnicode(false)
                    .HasColumnName("ED_logo");

                entity.Property(e => e.EdName)
                    .IsRequired()
                    .HasMaxLength(25)
                    .HasColumnName("ED_name");

                entity.Property(e => e.EdPicture)
                    .IsRequired()
                    .IsUnicode(false)
                    .HasColumnName("ED_picture");

                entity.Property(e => e.EdProfile)
                    .IsRequired()
                    .HasMaxLength(255)
                    .HasColumnName("ED_profile");

                entity.Property(e => e.EdState).HasColumnName("ED_state");

                entity.Property(e => e.EdTime)
                    .HasColumnType("date")
                    .HasColumnName("ED_time");

                entity.Property(e => e.EdType).HasColumnName("ED_type");

                entity.Property(e => e.PvcName)
                    .IsRequired()
                    .HasMaxLength(50)
                    .HasColumnName("PVC_name");

                entity.Property(e => e.UEmail)
                    .IsRequired()
                    .HasMaxLength(25)
                    .IsUnicode(false)
                    .HasColumnName("U_email");
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.HasKey(e => e.UEmail)
                    .HasName("PK__Users__BD4E74B527668428");

                entity.Property(e => e.UEmail)
                    .HasMaxLength(25)
                    .IsUnicode(false)
                    .HasColumnName("U_email");

                entity.Property(e => e.UCreateTime)
                    .HasColumnType("datetime")
                    .HasColumnName("U_createTime");

                entity.Property(e => e.UName)
                    .IsRequired()
                    .HasMaxLength(20)
                    .HasColumnName("U_name");

                entity.Property(e => e.UPassword)
                    .IsRequired()
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("U_password");

                entity.Property(e => e.USalt)
                    .IsRequired()
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("U_salt");

                entity.Property(e => e.UType).HasColumnName("U_type");
            });

            modelBuilder.Entity<Vote>(entity =>
            {
                entity.HasKey(e => e.EdId)
                    .HasName("PK__Votes__B9CF1800FA66D758");

                entity.Property(e => e.EdId)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("ED_id");

                entity.Property(e => e.VCount)
                    .IsRequired()
                    .HasMaxLength(10)
                    .IsUnicode(false)
                    .HasColumnName("V_count");
            });

            modelBuilder.Entity<VotingRecord>(entity =>
            {
                entity.HasKey(e => e.VrEmail)
                    .HasName("PK__VotingRe__0F7CFA85C5CC10FE");

                entity.ToTable("VotingRecord");

                entity.Property(e => e.VrEmail)
                    .HasMaxLength(25)
                    .IsUnicode(false)
                    .HasColumnName("VR_email");

                entity.Property(e => e.VrCount)
                    .IsRequired()
                    .HasMaxLength(10)
                    .IsUnicode(false)
                    .HasColumnName("VR_count");

                entity.Property(e => e.VrDate)
                    .HasColumnType("date")
                    .HasColumnName("VR_date");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
